package  
{
	import flash.display.Sprite;

	
	/**
	 * @author JCGray
	 * @version1.0.0
	 * @date May 6, 2011
	 * @client Tuesday Creative
	 * @project Giggle Go
	 * @langversion ActionScript3.0
	 */
	public class ShadowBox extends Sprite 
	{
		
		private var _chars:Array;
		private var _fl:Number = 100;
		private var _frame:Sprite;
		
		public function ShadowBox():void{
			
			_frame = new Sprite();
			 this.addChild(_frame);
			
		}
		
		// instead override add child to update info to rX and then add at approriate place.
		public function addShadowSprite(chr:ShadowSprite):void{
			
			if (!_chars){
				_chars = new Array();
			}
			
			if (chr.x != 0){
				chr.rX = chr.x;
				//chr.x = 0;
			}
			
			if (chr.y != 0){
				chr.rY = chr.y;
				//chr.y = 0;
			}
			
			if (chr.z != 0){
				chr.rZ = chr.z;
				chr.z = 0;
			}
		
			this.addChild(chr);
			_chars.push(chr);
			
		}
		
		public function updateAngles(val:Number):void
		{
			var sizeMod:Number;
			var perspectiveMod:Number;
			
			trace("val is " + val);
			
			for each (var chr:ShadowSprite in _chars){
				trace("z is " + chr.rZ);
				sizeMod = _fl/(_fl + chr.rZ);
				
				chr.scaleX = chr.scaleY = sizeMod;
				//chr.x = chr.rX * sizeMod;
				chr.x = chr.rX;
				chr.y = chr.rY * sizeMod;
				
			}

			updateFrame();
			
		}
		
		public function updateFrame():void
		{
			
			with (_frame.graphics){
				clear();
				lineStyle(1, 0x000000);
				moveTo(-300, -300);
				lineTo(_chars[0].x, _chars[0].y);
				moveTo(300, -300);
				lineTo(_chars[1].x, _chars[1].y);
				moveTo(300, 300);	
				lineTo(_chars[2].x, _chars[2].y);
				moveTo(-300, 300);
				lineTo(_chars[3].x, _chars[3].y);
				lineTo(_chars[0].x, _chars[0].y);
				lineTo(_chars[1].x, _chars[1].y);
				lineTo(_chars[2].x, _chars[2].y);
				lineTo(_chars[3].x, _chars[3].y);
			}
		}
		
		//override add child to update info to rX and then add at approriate place.
	}
}
